package com.wjw.java.oop.extends_;

/**
 * 继承的理论
 */
public class ExtendsTheory {
    public static void main(String[] args) {
        /**
         * 访问属性时：就近原则
         * 先看子类有没有,没有就往父类找,直到Object类
         */
        Son son  = new Son();
        System.out.println(son.name);//儿子
        System.out.println(son.age);//40
        System.out.println(son.hobby);//旅游
    }
}
class GrandPa{
    String name = "爷爷";
    String hobby = "旅游";
}
class Father extends GrandPa{
    String name = "爸爸";
    int age = 40;
}
class Son extends Father{
    String name = "儿子";
}